package com.lelv.framework.action;

import java.util.ArrayList;
import java.util.List;

import com.lelv.framework.bo.IAdminBo;
import com.lelv.framework.model.Admin;
import com.lelv.framework.plugin.Page;

public class AdminAction extends BaseAction{

	private IAdminBo adminBo;
	private Admin admin = new Admin();
	private List<Admin> admins = new ArrayList<Admin>();
	private Page page = new Page();

	public String adminLogin(){

		Long check = this.adminBo.checkLogin(admin);
		if(check == -1){
			return "loginError";
		}else{
			Admin sessionAdmin = this.adminBo.getAdminById(check);
			this.getSession().setAttribute("adminId", sessionAdmin.getAdminId());
			this.getSession().setAttribute("adminLevel", sessionAdmin.getAdminLevel());
			this.getSession().setAttribute("adminName", sessionAdmin.getAdminName());
			return "loginOK";
		}

	}

	public String getAdminList(){

		this.page = this.adminBo.getAdminPage(page);
		this.admins = page.getList();

		return "getAdminListOK";
	}

	public IAdminBo getAdminBo() {
		return adminBo;
	}

	public void setAdminBo(IAdminBo adminBo) {
		this.adminBo = adminBo;
	}

	public Admin getAdmin() {
		return admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public List<Admin> getAdmins() {
		return admins;
	}

	public void setAdmins(List<Admin> admins) {
		this.admins = admins;
	}
}
